<template>
  <div>

    <h3 align="center">车辆违章管理</h3>
    <el-table :data="userList" style="width: 100%">

      <el-table-column label="车牌号">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.carNo }}</span>
        </template>
      </el-table-column>

      <el-table-column label="警员编号">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.policeId }}</span>
        </template>
      </el-table-column>

      <el-table-column label="违规条例编号">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.ruleId }}</span>
        </template>
      </el-table-column>

      <el-table-column label="处理时间">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>

      <el-table-column label="处罚时间">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.updateTime }}</span>
        </template>
      </el-table-column>

      <el-table-column label="罚单状态">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.state }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
         <!-- <el-button v-if="scope.row.state !== '已结算'" size="mini" type="success" @click="pay(scope.row)">支付</el-button> -->
          <a v-if="scope.row.state !== '已结算'" target="_blank" href="http://localhost:8080/api/pay?carNo=111&ruleName=2222&money=123" type="success" >支付</a>
        </template>
      </el-table-column>
    </el-table>

    <div class="block">
      <!-- page-size 默认每页显示条数-->
      <el-pagination
        @size-change="selectPage"
        @current-change="handleCurrentChange"
        :current-page="curPage"
        :page-sizes="[1, 3, 5, 10]"
        :page-size="rows"
        layout="jumper,total, sizes, prev, pager, next"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  name: "violation",
  data() {
    return {
      userList: [],
      total: 0, //总条数
      totalPage: 0, //总页数
      curPage: 1, //当前页
      rows: 5, //每页显示条数,
      isShow: false
    }
  },
  methods: {
    //加载数据
    loaddata() {
      var mythis = this;
      $.ajax({
        url: "http://localhost:8080/api/getTicketRecord/渝F57091",
        type: "get",
        data: {
          "page": mythis.curPage,
          "row": mythis.rows
        },
        dataType: "json",
        success: function (data) {
          console.log(data)
          mythis.userList = data.info;
          mythis.total = data.total;
          mythis.totalPage = data.totalPage
        }
      })
    },
    //支付
    pay() {
      var mythis = this
      $.ajax({
        url: "http://localhost:8080/api/pay",
        type: "get",
        contentType: "application/json",
        dataType: "json",
        success: function (data) {
          mythis.$message("保存成功")
          //关闭模态框
          mythis.isShow = false;
          //刷新
          mythis.loaddata();
        },
        error: function (e) {
          console.log(e);
        }
      })
    },
    //用户选择页数
    selectPage(v) {
      this.rows = v;
      this.loaddata();
    },
    //当前页触发事件
    handleCurrentChange(v) {
      this.curPage = v;
      this.loaddata();
    },
  },
  mounted() {
    this.loaddata();
    console.log(this.$route.query.info)
  }

}
</script>

<style>
</style>
